package flex.cc.order.manage.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import flex.cc.base.dto.LoginAuthDto;
import flex.cc.core.utils.RequestUtil;
import flex.cc.order.manage.dao.OrderEvaluateDao;
import flex.cc.order.manage.dto.order.OrderEvaluateEntity;
import flex.cc.order.manage.dto.vo.OrderMainVo;
import flex.cc.order.manage.service.OrderEvaluateService;
import flex.cc.order.manage.service.OrderMainService;



@Service("orderEvaluateService")
@Transactional(rollbackFor = Exception.class)
public class OrderEvaluateServiceImpl extends ServiceImpl<OrderEvaluateDao, OrderEvaluateEntity> implements OrderEvaluateService {
    @Autowired
    private OrderEvaluateDao orderEvaluateDao;
    @Autowired
    private OrderMainService orderMainService;
	/**
	 *  1、保存评价信息
	 *  2、更新服务单表评价状态
	 * */
	@Override
	public void saveEvaluateInfo(OrderEvaluateEntity entity) {
		LoginAuthDto loginUser = RequestUtil.getLoginUser();
		entity.setCreater(loginUser.getUserCode());
		entity.setCreatedTime(new Date());
		orderEvaluateDao.saveEvaluateInfo(entity);
		//更新服务单主表评价状态
		OrderMainVo orderVo =new OrderMainVo();
		orderVo.setOrderNo(entity.getOrderNo());
		orderMainService.updateEvaluateByNo(orderVo);
	}

}
